//
//  MJTableViewNullDataView.m
//  来店易
//
//  Created by yejianping on 16/6/29.
//  Copyright © 2016年 u1city01. All rights reserved.
//

#import "MJTableViewNullDataView.h"
//#import "UIView+QM_Category.h"
#import "UIView+PGGExtension.h"
//#import "UIView+SDAutoLayout.h"
//#import "BaseAppConfig.h"
//#import "<#header#>"
@interface MJTableViewNullDataView ()


@property(nonatomic,strong)UILabel *descLabel;



@end

@implementation MJTableViewNullDataView

- (id)initWithFrame:(CGRect)frame {
    if (self=[super initWithFrame:frame]) {
        //self.backgroundColor = KHEXCOLOR(QM_Color_Bg);
        self.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.imageView];
        [self addSubview:self.messageLabel];
        [self addSubview:self.descLabel];
        [self addSubview:self.refreshBtn];
    }
    return self;
}

/**
 *  设置默认无数据视图
 */
- (void)setDefaultViewFrame {
    UIImage *image = [UIImage imageNamed:@"icon_emptyState_noData"];
    self.imageView.frame = CGRectMake((self.width-image.size.width)/2, self.height/4.2, image.size.width, image.size.height);
    self.imageView.image = image;
    
    self.messageLabel.frame = CGRectMake(30*SCALAE, self.imageView.bottom+40*SCALAE, self.width-60*SCALAE, 24*SCALAE);
   // self.messageLabel.backgroundColor=[UIColor redColor];
    self.messageLabel.text = @"暂无内容，先去其他地方逛逛吧！";
    
    self.descLabel.hidden = YES;
}

/**
 *  自定义图片文字无数据视图
 *
 *  @param imageName   图片名称
 *  @param message     提示信息
 */
- (void)setCustomViewFrame:(NSString *)imageName message:(NSString *)message {
    UIImage *image = [UIImage imageNamed:imageName];
    self.imageView.frame = CGRectMake((self.width-image.size.width)/2, self.height/4.2, image.size.width, image.size.height);
    self.imageView.image = image;
    self.imageView.userInteractionEnabled=YES;
    self.messageLabel.frame = CGRectMake(0, self.imageView.bottom+20*SCALAE, SCREEN_WIDTH, 24*SCALAE);
    self.messageLabel.text = message;
    self.messageLabel.font=[UIFont systemFontOfSize:14];
    self.messageLabel.textColor=KHEXCOLOR(@"#AFAFAF");
   // self.messageLabel.backgroundColor=[UIColor redColor];
    self.descLabel.hidden = YES;
    
}

/**
 *  发现页面无数据视图
 */
- (void)setFoundViewFrame {
    self.backgroundColor = [UIColor whiteColor];
    
    UIImage *image = [UIImage imageNamed:@"ic_empty_yizi"];
    self.imageView.frame = CGRectMake((self.width-image.size.width)/2, self.height/4.2, image.size.width, image.size.height);
    self.imageView.image = image;
    
    self.messageLabel.frame = CGRectMake(50*SCALAE, self.imageView.bottom+40*SCALAE, SCREEN_WIDTH-100*SCALAE, 24*SCALAE);
    self.messageLabel.text = @"这里一片荒凉~";
    self.messageLabel.font=[UIFont systemFontOfSize:14];
//    self.messageLabel.textColor = KHEXCOLOR(@"999999");

    self.descLabel.frame = CGRectMake(50*SCALAE, self.messageLabel.bottom+10*SCALAE, SCREEN_WIDTH-100*SCALAE, 24*SCALAE);
    self.descLabel.text = @"";
    self.descLabel.font=[UIFont systemFontOfSize:14];
//    self.descLabel.textColor = KHEXCOLOR(@"999999");
    
    self.descLabel.hidden = NO;
}
- (void)setCustomRefreshViewFrameWith:(NSString *)imageName message:(NSString *)message
{
    UIImage *image = [UIImage imageNamed:imageName];
    self.imageView.frame = CGRectMake((self.width-image.size.width)/2, self.height/4.2, image.size.width, image.size.height);
    self.imageView.image = image;
    //NSLog(@"aaaaaaaaaaaaaaaaaa");
    self.messageLabel.frame = CGRectMake(self.width/2-(self.width/2), self.imageView.bottom+20*SCALAE, self.width, 24*SCALAE);
    self.messageLabel.text = message;
    self.messageLabel.textAlignment=NSTextAlignmentCenter;
//    self.messageLabel.textColor = KHEXCOLOR(QM_Color_Gray);
    self.messageLabel.font=[UIFont systemFontOfSize:14];
  // self.messageLabel.backgroundColor=[UIColor redColor];
    self.descLabel.hidden = YES;
    
    _refreshBtn.frame=CGRectMake((self.width-image.size.width)/2, self.messageLabel.bottom+50*SCALAE, image.size.width, 88*SCALAE);
    [_refreshBtn setTitle:@"刷新一下" forState:UIControlStateNormal];
    
    
    
}
/**
 *  无数据显示图标
 *
 *  @return <#return value description#>
 */
- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
    }
    return _imageView;
}

/**
 *  无数据提示信息
 *
 *  @return <#return value description#>
 */
- (UILabel *)messageLabel {
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc] init];
        _messageLabel.font = [UIFont systemFontOfSize:14];
        _messageLabel.backgroundColor = [UIColor clearColor];
        _messageLabel.textAlignment = NSTextAlignmentCenter;
//        _messageLabel.textColor = KHEXCOLOR(@"999999");
        _messageLabel.numberOfLines = 0;
    }
    return _messageLabel;
}

/**
 *  无数据提示信息
 *
 *  @return <#return value description#>
 */
- (UILabel *)descLabel {
    if (!_descLabel) {
        _descLabel = [[UILabel alloc] init];
        _descLabel.font = [UIFont systemFontOfSize:14];
        _descLabel.backgroundColor = [UIColor clearColor];
        _descLabel.textAlignment = NSTextAlignmentCenter;
//        _descLabel.textColor = KHEXCOLOR(@"999999");
    }
    return _descLabel;
}

-(UIButton*)refreshBtn
{
    if (!_refreshBtn) {
        _refreshBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        _refreshBtn.layer.masksToBounds=YES;
        _refreshBtn.layer.cornerRadius=10*SCALAE;
       // _refreshBtn.backgroundColor=
        _refreshBtn.titleLabel.font=[UIFont systemFontOfSize:16];
        
        [_refreshBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _refreshBtn.backgroundColor=[UIColor colorWithRed:252/255.0 green:229/255.0 blue:78/255.0 alpha:1];
       // _refreshBtn.backgroundColor=[UIColor redColor];
    }
    return _refreshBtn;
    
}
@end
